/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.dataserializer.serializer;

import com.inspur.edp.bef.bizentity.GspBizEntityObject;
import com.inspur.edp.bef.dtgenerator.core.rtgen.entitygen.dataserializer.deserialize.BeNodeDataDeserializerGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.ManagerGeneratorContext;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.deserializer.EntityNodeDataDeserGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.serializer.EntityDataSerGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.dataser.serializer.entity.EntityNodeDataSerGenerator;
import com.inspur.edp.das.commonmodel.IGspCommonObject;

public class BefEntityDataSerializerGenerator extends EntityDataSerGenerator {

    public BefEntityDataSerializerGenerator(ManagerGeneratorContext mgrContext) {
        super(mgrContext);
    }

    //private new EntityDataSerializerGenContext Context => base.Context as EntityDataSerializerGenContext;
    @Override
    protected EntityNodeDataSerGenerator createEntityNodeDataSerClassGenerator(IGspCommonObject object) {
        return new BENodeDataSerGenerator((GspBizEntityObject) object, null, getDataSerGenContext());
    }

    @Override
    protected EntityNodeDataDeserGenerator createEntityNodeDataDeserClassGenerator(IGspCommonObject object) {
        return new BeNodeDataDeserializerGenerator((GspBizEntityObject) object, null, getDataSerGenContext());
    }

    //protected override CompositeGeneratorContext CreateCompositeContext()
    //{
    //    EntityDataSerializerGenContext context = new EntityDataSerializerGenContext(entityDataGenContext);
    //    entityDataGenContext.EntityDataSerializerGenContext = context;
    //    return context;
    //}

    //protected override List<BaseGenerator> CreateCompositeItemGenerators()
    //{
    //    List<Type> serializerTypes = new List<Type>();
    //    List<Type> entityTypes = new List<Type>();
    //    string objectCode = string.Empty;
    //    foreach (var item in Context.EntityDataGenContext.FsGenContext.MgrInterfaceAndType)
    //    {
    //        var implType = item.ImplType;
    //        var extendAttrs = implType.GetCustomAttributes(typeof(VMDataExtendAttribute), false);
    //        if (extendAttrs.Length > 0)
    //        {
    //            var serType = (extendAttrs[0] as VMDataExtendAttribute).SerializerType;
    //            if (serType != null)
    //                serializerTypes.Add(serType);
    //            Type entityDataType = (extendAttrs[0] as VMDataExtendAttribute).EntityDataType;
    //            entityTypes.Add(entityDataType);
    //            var rootAttributes = entityDataType.GetCustomAttributes(typeof(VMRootAttribute), false);
    //            if (rootAttributes != null && rootAttributes.Length != 0)
    //                objectCode = (rootAttributes[0] as VMRootAttribute).ObjectCode;
    //        }
    //    }
    //    return new List<BaseGenerator>() { new VmNodeDataSerGenerator(objectCode, true, serializerTypes, entityTypes, null, Context) };
    //}
}
